package com.openvas.controller;

import java.util.List;
//    import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.openvas.commons.common.annotation.Log;
import com.openvas.commons.common.enums.BusinessType;
import com.openvas.domain.TableResult;
import com.openvas.service.ITableResultService;
import com.openvas.commons.common.core.controller.BaseController;
import com.openvas.commons.common.core.domain.AjaxResult;

import com.openvas.commons.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ruoyi
 * @date 2021-11-04
 */
@Controller
@RequestMapping("/api/result")
public class TableResultController extends BaseController
{
    private String prefix = "system/result";

    @Autowired
    private ITableResultService tableResultService;

   // //  @RequiresPermissions("system:result:view")
    @GetMapping()
    public String result()
    {
        return prefix + "/result";
    }

    /**
     * 查询【请填写功能名称】列表
     */
   // //  @RequiresPermissions("system:result:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TableResult tableResult)
    {
        startPage();
        List<TableResult> list = tableResultService.selectTableResultList(tableResult);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
   // //  @RequiresPermissions("system:result:export")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TableResult tableResult)
    {
        List<TableResult> list = tableResultService.selectTableResultList(tableResult);
//        ExcelUtil<TableResult> util = new ExcelUtil<TableResult>(TableResult.class);
//        return util.exportExcel(list, "【请填写功能名称】数据");
        return null;
    }

    /**
     * 新增【请填写功能名称】
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存【请填写功能名称】
     */
   // //  @RequiresPermissions("system:result:add")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TableResult tableResult)
    {
        return toAjax(tableResultService.insertTableResult(tableResult));
    }

    /**
     * 修改【请填写功能名称】
     */
    @GetMapping("/edit/{resultId}")
    public String edit(@PathVariable("resultId") String resultId, ModelMap mmap)
    {
        TableResult tableResult = tableResultService.selectTableResultByResultId(resultId);
        mmap.put("tableResult", tableResult);
        return prefix + "/edit";
    }

    /**
     * 修改保存【请填写功能名称】
     */
   // //  @RequiresPermissions("system:result:edit")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TableResult tableResult)
    {
        return toAjax(tableResultService.updateTableResult(tableResult));
    }

    /**
     * 删除【请填写功能名称】
     */
   // //  @RequiresPermissions("system:result:remove")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tableResultService.deleteTableResultByResultIds(ids));
    }
}
